﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LTP.Common
{
    public class SendSMS
    {
        public static bool Send(IDictionary<string, string> contentList)
        {
            try
            {
                StringBuilder phone = new StringBuilder();
                StringBuilder content = new StringBuilder();

                foreach (KeyValuePair<string, string> value in contentList)
                {
                    phone.Append(string.Format(",{0}", value.Key));
                    content.Append(string.Format(",{0}", value.Value.Replace(",", "，")));
                }

                string[] args = { LTP.Common.ConfigHelper.GetConfigString("SendSMSSn"), LTP.Common.StringClass.EncryptPassword(LTP.Common.ConfigHelper.GetConfigString("SendSMSSn") + LTP.Common.ConfigHelper.GetConfigString("SendSMSPwd"), LTP.Common.StringClass.PasswordFormat.MD5_32), phone.Remove(0, 1).ToString(), content.Remove(0, 1).ToString(), "", "", "" };

                string result = WebserviceClass.WSHelper.InvokeWebService(LTP.Common.ConfigHelper.GetConfigString("SendSMSUrl"), "gxmt", args).ToString();

                if (LTP.Common.CheckInput.CheckDigit(result) && int.Parse(result) > 0)
                    return true;
                else
                    return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
